/*
 * Created by JFormDesigner on Fri Nov 15 14:47:19 CST 2024
 */

package com.hafu.view.GYS;
import javax.swing.table.*;
import com.hafu.model.GysInfo;
import com.hafu.service.GysInfoService;
import com.hafu.util.StringUtil;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.GroupLayout;


/**
 * @author
 */
public class AddGYSFrm extends JFrame {
    private GysInfoService gysInfoService=new GysInfoService();
    public void AddGYSFrm(){
        initComponents();
    }
    private void setTijiaobutton(ActionEvent e){

        String name = textField1.getText();
        String tel=textField2.getText();
        if(StringUtil.isEmpty(name)){
            JOptionPane.showMessageDialog(null,"供应商名称不能为空");
            return;
        }
        if(StringUtil.isEmpty(tel)){
            JOptionPane.showMessageDialog(null,"供应商电话不能为空");
            return;
        }
        GysInfo gysInfo=new GysInfo(name,tel);
        Boolean aBoolean=gysInfoService.addGysInfo(gysInfo);
        if(aBoolean){
            JOptionPane.showMessageDialog(null,"添加成功");
            this.dispose();
        }else{
            JOptionPane.showMessageDialog(null,"添加失败");
        }
    }

    private void button1(ActionEvent e) {
        // TODO add your code here
    }

    private void tijiaobutton(ActionEvent e) {
        // TODO add your code here
    }


    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        label1 = new JLabel();
        label2 = new JLabel();
        tijiaobutton = new JButton();
        textField1 = new JTextField();
        textField2 = new JTextField();

        //======== this ========
        Container contentPane = getContentPane();

        //---- label1 ----
        label1.setText("\u4f9b\u5e94\u5546\u540d\u5b57");

        //---- label2 ----
        label2.setText("\u4f9b\u5e94\u5546\u7535\u8bdd");

        //---- tijiaobutton ----
        tijiaobutton.setText("\u63d0\u4ea4");
        tijiaobutton.addActionListener(e -> {
			button1(e);
			tijiaobutton(e);
		});

        GroupLayout contentPaneLayout = new GroupLayout(contentPane);
        contentPane.setLayout(contentPaneLayout);
        contentPaneLayout.setHorizontalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addGroup(contentPaneLayout.createParallelGroup()
                        .addGroup(contentPaneLayout.createSequentialGroup()
                            .addGap(44, 44, 44)
                            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                .addGroup(contentPaneLayout.createSequentialGroup()
                                    .addComponent(label1)
                                    .addGap(18, 18, 18)
                                    .addComponent(textField1, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE))
                                .addGroup(contentPaneLayout.createSequentialGroup()
                                    .addComponent(label2)
                                    .addGap(18, 18, 18)
                                    .addComponent(textField2))))
                        .addGroup(contentPaneLayout.createSequentialGroup()
                            .addGap(116, 116, 116)
                            .addComponent(tijiaobutton)))
                    .addContainerGap(361, Short.MAX_VALUE))
        );
        contentPaneLayout.setVerticalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addGap(35, 35, 35)
                    .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(label1)
                        .addComponent(textField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(label2)
                        .addComponent(textField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addGap(36, 36, 36)
                    .addComponent(tijiaobutton)
                    .addContainerGap(535, Short.MAX_VALUE))
        );
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    private JLabel label1;
    private JLabel label2;
    private JButton tijiaobutton;
    private JTextField textField1;
    private JTextField textField2;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}